Don't leak info_ptr.
authorMatthias Clasen <matthiasc@src.gnome.org>
Wed, 27 Mar 2002 22:12:05 +0000 (22:12 +0000)
committerMatthias Clasen <matthiasc@src.gnome.org>
Wed, 27 Mar 2002 22:12:05 +0000 (22:12 +0000)
* io-png.c (gdk_pixbuf__png_image_stop_load): Don't leak info_ptr.

* io-png.c (gdk_pixbuf__png_image_load): Get rid of unused
end_info. Also call png_read_end to check proper ending of the png
file and catch text chunks after the image data.

gdk-pixbuf/ChangeLog
gdk-pixbuf/io-png.c

index c7e368af0bc7e628a856a6b7a70091ccde45a963..c8e6183bddcdc267b6189144ea23b8eda2123927 100644 (file)
@@ -1,3 +1,11 @@
+2002-03-27  Matthias Clasen  <maclas@gmx.de>
+
+       * io-png.c (gdk_pixbuf__png_image_stop_load): Don't leak info_ptr.
+
+       * io-png.c (gdk_pixbuf__png_image_load): Get rid of unused
+       end_info. Also call png_read_end to check proper ending of the png
+       file and catch text chunks after the image data.
+
 2002-03-27  Matthias Clasen  <maclas@gmx.de>
 
        * io-png.c (gdk_pixbuf__png_image_load,
index 3038e74e28b34d995c5ef275d3cbbd7ad3d1f950..66f99fdfe187b2892346c3ea1dd26f3a6d5fefbf 100644 (file)
@@ -240,7 +240,7 @@ gdk_pixbuf__png_image_load (FILE *f, GError **error)
 {
         GdkPixbuf *pixbuf;
        png_structp png_ptr;
-       png_infop info_ptr, end_info;
+       png_infop info_ptr;
         png_textp text_ptr;
        gint i, ctype, bpp;
        png_uint_32 w, h;
@@ -272,12 +272,6 @@ gdk_pixbuf__png_image_load (FILE *f, GError **error)
                return NULL;
        }
 
-       end_info = png_create_info_struct (png_ptr);
-       if (!end_info) {
-               png_destroy_read_struct (&png_ptr, &info_ptr, NULL);
-               return NULL;
-       }
-
        if (setjmp (png_ptr->jmpbuf)) {
                if (rows)
                        g_free (rows);
@@ -285,7 +279,7 @@ gdk_pixbuf__png_image_load (FILE *f, GError **error)
                if (pixels)
                        g_free (pixels);
 
-               png_destroy_read_struct (&png_ptr, &info_ptr, &end_info);
+               png_destroy_read_struct (&png_ptr, &info_ptr, NULL);
                return NULL;
        }
 
@@ -293,7 +287,7 @@ gdk_pixbuf__png_image_load (FILE *f, GError **error)
        png_read_info (png_ptr, info_ptr);
 
         if (!setup_png_transformations(png_ptr, info_ptr, error, &w, &h, &ctype)) {
-                png_destroy_read_struct (&png_ptr, &info_ptr, &end_info);
+                png_destroy_read_struct (&png_ptr, &info_ptr, NULL);
                 return NULL;
         }
         
@@ -314,7 +308,7 @@ gdk_pixbuf__png_image_load (FILE *f, GError **error)
                                      _("Insufficient memory to load PNG file"));
                 }
                 
-               png_destroy_read_struct (&png_ptr, &info_ptr, &end_info);
+               png_destroy_read_struct (&png_ptr, &info_ptr, NULL);
                return NULL;
        }
 
@@ -324,6 +318,7 @@ gdk_pixbuf__png_image_load (FILE *f, GError **error)
                rows[i] = pixels + i * w * bpp;
 
        png_read_image (png_ptr, rows);
+        png_read_end (png_ptr, info_ptr);
 
         if (png_get_text (png_ptr, info_ptr, &text_ptr, &num_texts)) {
                 options = g_new (gchar *, num_texts * 2);
@@ -333,7 +328,7 @@ gdk_pixbuf__png_image_load (FILE *f, GError **error)
                                                    options + 2*i + 1);
                 }
         }
-       png_destroy_read_struct (&png_ptr, &info_ptr, &end_info);
+       png_destroy_read_struct (&png_ptr, &info_ptr, NULL);
        g_free (rows);
 
        if (ctype & PNG_COLOR_MASK_ALPHA)
@@ -511,7 +506,7 @@ gdk_pixbuf__png_image_stop_load (gpointer context, GError **error)
         if (lc->pixbuf)
                 g_object_unref (lc->pixbuf);
         
-        png_destroy_read_struct(&lc->png_read_ptr, NULL, NULL);
+        png_destroy_read_struct(&lc->png_read_ptr, &lc->png_info_ptr, NULL);
         g_free(lc);
 
         return TRUE;